package com.hzdesk.media.matvector.koreabatch.client.my_paperless.custom_view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;

/**
 * Created by Administrator on 2018/8/21.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class CursorColorView extends View {
    private int paithColor = 0xff3c3cff;
    private int width;
    private int height;
    private Paint mpaint;

    public CursorColorView(Context context) {
        this(context,null);
    }

    public CursorColorView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public CursorColorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        mpaint = new Paint();
        mpaint.setAntiAlias(true);
        mpaint.setColor(paithColor);
        mpaint.setStyle(Paint.Style.FILL);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        width = MeasureSpec.getSize(widthMeasureSpec);
        height = MeasureSpec.getSize(heightMeasureSpec);
        if(width >= height){
            height = width;
        }
        setMeasuredDimension(width, height);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mpaint.setColor(paithColor);
        canvas.drawCircle(width/2,width/2,width/2,mpaint);
    }
    /**
     * @desc 设置颜色
     * */
    public void setCursorColor(int Color){
        paithColor = Color;
        invalidate();
    }
}
